/*
 * Author: xiguan
 * Mail: xiguan.teng@qq.com
 * -----
 * Last Modified: 2022-05-31 22:08:01
 * Modified By: xiguan
 * -----
 * Copyright (c) 2022 XiGuan Inc.
 * 
 * No Bug No error No warning.
 */



#include <bits/stdc++.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>


using namespace std;


int main(int argc, char *argv[]){

    pid_t pid;
    char *msg;
    int k;

    printf("Press Creation Study\n");
    pid = fork();
    switch(pid){
        case 0:{
            msg = (char *)"Child process is running";
            k = 3;
            break;
        }
        case -1:{
            perror("fork");
            exit(0);
            break;
        }
        default:{
            k = 5;
            msg = (char *)"Parent process is running";
            break;
        }
    }
    
    while(k > 0){
        puts(msg);
        sleep(1);
        k --;
    }

    return 0;
}